#ifndef DECODER_HPP
#define DECODER_HPP

#include <QObject>
#include <QMap>
#include <QMapIterator>
#include <QStringList>
#include <QDebug>
#include <QList>

#include "command.hpp"

/**
* @brief Class Decoder is used to decode the given information of the LST file
* @details This Class is used to get all information of the loaded LST file \n
* The decode function is called for every line of the LST file and will return a Command object. \n
* The seperation of this line will be done with regular expressions. \n
* Content will be saved seperately in Command (ASM-Code, line number, programMemory address, Comment, ...)
* @see Command decodeLstString(QString line)
*
* @class Decoder decoder.hpp "decoder.hpp"
*/
class Decoder : public QObject
{
Q_OBJECT
public:
    /**
    * @brief Constructor for Decoder
    *
    * @fn explicit Decoder(QObject *parent = 0)
    * @param parent
    */
    explicit Decoder(QObject *parent = 0);

    /**
    * @brief Copy Constructor for Decoder
    *
    * @fn Decoder(const Decoder &other)
    * @param other
    */
    Decoder(const Decoder &other);

    /**
    * @brief Destructor for Decoder
    *
    * @fn ~Decoder
    */
    ~Decoder();

    /**
    * @brief Decode a given String into a Command Object
    *
    * @fn Command decodeLstString(QString line)
    * @param line
    * @return Command
    */
    Command decodeLstString(QString line);

    /**
    * @brief Reset all saved entries and prepare for a new program
    *
    * @fn void reset()
    */
    void reset();

    /**
    * @brief Returns the map containing all label strings and addresses
    *
    * @fn const QMap<QString, int> &getLabelMap() const
    * @return const QMap<QString, int>
    */
    const QMap<QString, int> &getLabelMap() const;

    /**
    * @brief Returns the map containing all equ strings and addresses
    *
    * @fn const QMap<QString, int> &getEquMap() const
    * @return const QMap<QString, int>
    */
    const QMap<QString, int> &getEquMap() const;

private:
    QMap<QString, int> equMap;
    QMap<QString, int> labelMap;
    QList<QString> pendingLabels;

signals:
    void customHighlightingRule(QString pattern, int type);
    void customTooltip(QString var, QString tooltip);
    void variableFound(QString name, QString address);

};

#endif // DECODER_HPP
